#include "echoserver.h"

void EchoServer::OnConn(tlib::TSocket* sock)
{
	log_debug("Socket[%d] OnConn..", sock->fd());
}

void EchoServer::OnRecv(tlib::TSocket* sock)
{
	//log_debug("Socket[%d] OnRecv..", sock->fd());
	int len = sock->GetReadAbleLen();
	if (len > 0)
	{
		char buff[8192] = { 0 };
		if (sock->ReadBuffer(buff, len))
		{
			sock->Send(buff, len);
		}
	}
}

void EchoServer::OnClose(tlib::TSocket* sock)
{
	log_debug("Socket[%d] OnClose..", sock->fd());
}